<template>
  <div>
    <el-card class="box-card main-table-card">
      <div slot="header" class="clearfix">
        <el-form ref="queryForm" :model="query" label-width="80px">
          <el-button type="primary" >搜索</el-button>

          <el-button type="primary" v-if="button.type == 'BUTTON_TOP'"  v-for="button in $store.state.buttons" :key="button.id" @click="handleClick('',button.name)">{{button.title}}</el-button>
        </el-form>
      </div>
      <tree-table :data="data" @clickCallback="handleClick" :columns="columns" border/>
    </el-card>
  </div>
</template>

<script>
import treeTable from "@/common/components/treeTable/Index";
import global from "@/common/components/Global"
import axios from "@/common/js/axios"
export default {
  name: '',
  components: { treeTable },
  data() {
    return {
      columns: [
        {
          text: "ID",
          value: "id"
        },
        {
          text: "标题",
          value: "title",
        },
        {
          text: "前端路由",
          value: "url"
        },
        {
          text: "名称",
          value: "name"
        },
        {
          text: "类型",
          value: "type"
        },
        {
          text: "父权限ID",
          value: "parentId"
        },
        {
          text: "样式",
          value: "icon"
        },
        {
          text: "排序",
          value: "sort"
        },
      ],
      data: []
    };
  },
  created(){
    let _this = this;
    _this.treeList();
  },
  methods:{
    treeList(){
      let _this = this;
      axios.post(global.adminBackEndApi + "sys/admin-menu/listTree").then(response=>{
        _this.data = response.data.data;
      })
    },
    handleClick(row,button){
      switch (button) {
        case 'add': {

          this.$message.warning("添加")
          break;
        }
        case 'edit': {
          this.$message.warning("编辑")
          break;
        }
        case 'del': {
          this.$message.warning("删除")
          break;
        }
      }
    }
  }

}
</script>

<style scoped>
  .main-table-card{
    min-height: 400px;
  }
  .search-form{
    margin-top: 0px;
    padding-top:0px;
  }

</style>
